package com.zhaohanlin.start;

import org.junit.Test;

import java.util.Random;

/**
 * @author zhaohanlin
 */
public class TestOne {

    @Test
    public void ifStructure() {
        int score = new Random().nextInt(101);
        System.out.println("score: " + score);

        // if(条件){满足条件时执行的代码}
        if (score >= 60) {
            System.out.println("你及格了...");
        }

        // if(条件){满足条件时执行的代码} else {其他情况}
        if (score >= 60) {
            System.out.println("你及格了...");
        } else {
            System.out.println("你没及格...");
        }

        // if(条件){满足条件时执行的代码} else if(条件) {满足条件时执行的代码} else {其他情况}
        if (score >= 80) {
            System.out.println("你很优秀...");
        } else if (score >= 60) {
            System.out.println("你及格了...");
        } else if (score >= 0) {
            System.out.println("你没及格...");
        } else {
            System.out.println("分数异常...");
        }
    }

    @Test
    public void switchStructure() {
        int num = new Random().nextInt(5);
        System.out.println("num: " + num);
        switch (num + 1) {
            case 1:
                System.out.println("你的数字是0...");
                break;
            case 2:
                System.out.println("你的数字是1...");
                break;
            case 3:
                System.out.println("你的数字是2...");
                break;
            case 4:
                System.out.println("你的数字是3...");
                break;
            case 5:
                System.out.println("你的数字是4...");
                break;
            default:
                System.out.println("数字有问题...");
                break;
        }
    }

}

